package util;

import com.alibaba.fastjson.JSONObject;

public class UserUtil {

	public static final String appid = "wx462c0cffeb99410a";
	public static final String secret = "d487be58decd47ee59c8e786c62efc3b";
	public static final String grant_type = "authorization_code";
	
	public static String getWechatId(String code){
		String url = "https://api.weixin.qq.com/sns/jscode2session?appid="+appid+"&secret="+secret+"&js_code="+code+"&grant_type="+grant_type;
		String result = URLUtil.request(url);
		if(result==null){
			return null;
		}
        return JSONObject.parseObject(result).getString("openid");
	}
}
